<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <input type="text" name="" id="ipt">
    <button>点击</button>
    <span>nih</span>
    <script>
        var allGoods = []
        var code = '';
        var lastTime, nextTime;
        var lastCode;

        document.addEventListener('keydown', e => {
            const event = e || window.event;
            if (event.keyCode === 13) {
                if (code.length < 3) {
                    return
                }
                code = '';
                lastCode = '';
                lastTime = 0;
                return
            }

        }, false)



        // 监听搜索框回车事件
        const input = document.querySelector('input')
        input.addEventListener('keydown', function (e) {
            console.log(e.target.value);
            if (e.keyCode == 13) {
                // console.log("回车键被按下")
                console.log(e.target.value);
            }
        });




    </script>
</body>

</html>